package com.gh.lucene.index;

import java.io.IOException;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.LockObtainFailedException;

import com.gh.lucene.Lucenes;

public class IndexTest {

	public static void main(String[] args) {

		Analyzer ik = Lucenes.IKAnalyzerHolder.INSTANCE.getAnaylzer();

		Directory directory = null;
		try {
			directory = Lucenes.getSimpleFileSystemDirectory("index");
		} catch (IOException e) {
			e.printStackTrace();
		}

		IndexWriter writer = null;
		try {
			writer = Lucenes.createIndexWriter(directory, ik);
			
			
			
			
			
			
		} catch (CorruptIndexException e) {
			e.printStackTrace();
		} catch (LockObtainFailedException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				writer.close();
			} catch (CorruptIndexException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}
